package cn.com.egova.mahjong;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;

public class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setBackIconVisible(isBackIconVisible());
    }


    /**
     * 设置是否在菜单栏显示返回按钮图标.
     * @param isVisible
     */
    public void setBackIconVisible(boolean isVisible){
        ActionBar actionBar = getActionBar();
        if(null != actionBar) {
            actionBar.setDisplayHomeAsUpEnabled(isVisible);
            actionBar.setDisplayShowHomeEnabled(false);
        }
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public boolean isBackIconVisible() {
        return false;
    }
}
